package com.itheima.dao;

import com.itheima.pojo.SysDictData;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;

/**
 * @author xuchangshuo
 * @date 2020/8/4 10:11
 */
public interface SysDictDataMapper extends Mapper<SysDictData> {

    //根据dict_type_uid查询SysDictData的数量
    @Select("select count(*) from t_sys_dict_data where dict_type_uid=#{dict_type_uid}")
    int getSysDictDataCount(@Param("dict_type_uid") String dict_type_uid);
    // //根据字典类型数组获取字典数据
    @Select("select * from t_sys_dict_data where dict_type_uid = #{uid}")
    @Results({@Result(column = "dict_type_uid", property = "dictTypeUid"),
            @Result(column = "dict_label", property = "dictLabel"),
            @Result(column = "dict_value", property = "dictValue"),
            @Result(column = "css_class", property = "cssClass"),
            @Result(column = "list_class", property = "listClass"),
            @Result(column = "is_default", property = "isDefault"),
            @Result(column = "create_by_uid", property = "createByUid"),
            @Result(column = "update_by_uid", property = "updateByUid"),
            @Result(column = "update_time", property = "updateTime"),
            @Result(column = "is_publish", property = "isPublish"),
            @Result(column = "create_time", property = "createTime")})
    List<SysDictData> getListByDictType(@Param("uid") String uid);
}
